package com.example.its2021606134chh.MyMessageModule;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.its2021606134chh.R;

import java.util.List;

/**
 * @ClassName: ListViewAdapter$
 * @Description: 作用
 * @Author: letquit
 * @CreateDate: 2021/6/20$
 * @Version: 1.0
 */
public class ListViewAdapter extends BaseAdapter {
    private List<MessageParams> list;
    private Context context;
    private LayoutInflater inflater;
    private TextView tvMMListViewID;
    private TextView tvMMListViewType;
    private TextView tvMMListViewThreshold;
    private TextView tvMMListViewValues;

    public ListViewAdapter(List<MessageParams> list, Context context) {
        this.list = list;
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    public List<MessageParams> getList() {
        return list;
    }

    public void setList(List<MessageParams> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = inflater.inflate(R.layout.mm_listview_heard, null);
        tvMMListViewID = (TextView) view.findViewById(R.id.tvMMListViewID);
        tvMMListViewType = (TextView) view.findViewById(R.id.tvMMListViewType);
        tvMMListViewThreshold = (TextView) view.findViewById(R.id.tvMMListViewThreshold);
        tvMMListViewValues = (TextView) view.findViewById(R.id.tvMMListViewValues);
        tvMMListViewID.setText(String.valueOf(position+1));
        tvMMListViewType.setText(list.get(position).getType());
        tvMMListViewThreshold.setText(list.get(position).getThreshold());
        tvMMListViewValues.setText(list.get(position).getValues());
        return view;
    }

}
